#ifndef SOCKETHANDLER_H
#define SOCKETHANDLER_H

#include <QObject>
#include <QTcpSocket>
#include "../MeetingServer/messagepackage.h"


class socketHandler : public QObject
{
    Q_OBJECT
public:
    static socketHandler *getInstance();
    static void removeInstance();

    QTcpSocket *getSocket() const;
    bool connectServe(QString ip, int port);

private:
    explicit socketHandler(QObject *parent = nullptr);
    ~socketHandler();
    static socketHandler* instance;
    QString userName = nullptr;
    QTcpSocket* socket = nullptr;

private slots:
    void onReadyRead();
signals:
    void regState(bool);
    void logState(int);
    void onlineUsers(QStringList);
    void privateChat(messagePackage pack);
    void allUsers(QStringList);
    void createGroupState(messagePackage);
    void groupChat(messagePackage pack);
    void addGroup(QString groupName);
    void upload(bool ret);
    void allFile(QStringList file);
    void downloadFile(messagePackage pack);
    void groupFile(messagePackage pack);
    void retMeeting(messagePackage pack);
    void inviteMeeting(messagePackage pack);
    void updateMeeting(messagePackage pack);
    void clearMeeting();
};

#endif // SOCKETHANDLER_H
